package io.kogoro.banner;

import org.springframework.boot.Banner;
import org.springframework.boot.SpringBootVersion;
import org.springframework.boot.ansi.AnsiColor;
import org.springframework.boot.ansi.AnsiOutput;
import org.springframework.core.env.Environment;

import java.io.PrintStream;

/**
 * @author he peng
 */
public class KogoroBanner implements Banner {

    private static final String[] BANNER = {"   ▄█   ▄█▄  ▄██████▄     ▄██████▄   ▄██████▄     ▄████████  ▄██████▄\n" +
            "  ███ ▄███▀ ███    ███   ███    ███ ███    ███   ███    ███ ███    ███\n" +
            "  ███▐██▀   ███    ███   ███    █▀  ███    ███   ███    ███ ███    ███\n" +
            " ▄█████▀    ███    ███  ▄███        ███    ███  ▄███▄▄▄▄██▀ ███    ███\n" +
            "▀▀█████▄    ███    ███ ▀▀███ ████▄  ███    ███ ▀▀███▀▀▀▀▀   ███    ███\n" +
            "  ███▐██▄   ███    ███   ███    ███ ███    ███ ▀███████████ ███    ███\n" +
            "  ███ ▀███▄ ███    ███   ███    ███ ███    ███   ███    ███ ███    ███\n" +
            "  ███   ▀█▀  ▀██████▀    ████████▀   ▀██████▀    ███    ███  ▀██████▀\n" +
            "  ▀                                              ███    ███"};

    public void printBanner(Environment environment, Class<?> sourceClass, PrintStream printStream) {
        for (String line : BANNER) {
            printStream.println(AnsiOutput.toString(AnsiColor.BLUE , line));
        }
        String version = SpringBootVersion.getVersion();
        version = (version != null) ? " (v" + version + ")" : "";
        printStream.println(AnsiOutput.toString(AnsiColor.BLUE , "               power by Spring Boot " + version));
        printStream.println();
    }
}
